<?php

function sendEmail($FromEmail,$Subject,$Message,$FromName,array $ToEmail) {
        require("lib/PHPMailer/class.phpmailer.php");
        $mail = new PHPMailer();   
        $mail->From     = $FromEmail;
        $mail->FromName = $FromName;         
        $mail->IsSMTP();        
        $mail->SMTPAuth = true;     // turn of SMTP authentication
        $mail->Username = "qmriso_cpgtcorp@yahoo.co.id";  // SMTP username  (Ex: sumithnets@yahoo.com)
        $mail->Password = "QMS9001ohsas18001"; // SMTP password  (Ex: yahoo email password)
        $mail->SMTPSecure = "ssl";        
        $mail->Host = "smtp.mail.yahoo.com";
        $mail->Port = 465;         
        $mail->SMTPDebug  = 2; // Enables SMTP debug information (for testing, remove this line on production mode)
         // 1 = errors and messages
         // 2 = messages only         
        $mail->Sender   =  $FromEmail;// $bounce_email;
        $mail->ConfirmReadingTo  = $FromEmail;         
        $mail->AddReplyTo($FromEmail);
        $mail->IsHTML(true); //turn on to send html email
        $mail->Subject = $Subject;        
        $mail->Body     =  $Message;
        $mail->AltBody  =  "ALTERNATIVE MESSAGE FOR TEXT WEB BROWSER LIKE SQUIRRELMAIL";      
     
	 	foreach($ToEmail as $email => $name)
		{
			   $mail->AddCC($email, $name);
		}	   
		 if($mail->Send()){
		 	 $mail->ClearAddresses();  
		 }
 
 }
 
 $FromEmail =   'qmriso_cpgtcorp@yahoo.co.id'; //sumithnets@yahoo.com
 $Subject   =   'DOCUMENT CONTROL ISO';  
 $Message   =   'Piraku teu ica mah.. ';  
 $FromName  =   'FROM NAME';  // Sumith Harshan
// $ToEmail   =   'ricky.kuasep@gmail.com';  //sumith.harshan@gmail.com
 $ToEmail = array(
		   'mricky.it@gmail.com' => 'Person One',
		   'ricky.kuasep@gmail.com' => 'Person Two',
		 //  'ismail_fath@yahoo.com' => 'Person Three',
		   // ..
		);
 $response  = sendEmail($FromEmail,$Subject,$Message,$FromName,$ToEmail);
    // $response  = sendEmail($FromEmail,$Subject,$Message,$FromName,$ToEmail);
 print_r($response);
if (function_exists('sendEmail')) {
    echo "FUNGSI PENGIRIMAN EMAIL TERSEDIA.<br />\n";
} else {
    echo "FUNGSI PENGIRIMAN EMAIL TIDAK TERSEDIA.<br />\n";
}

 ?>